<?php

namespace App\Repositories;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\StaffDormAdjustRepository;
use App\Models\StaffDormAdjust;
use App\Validators\StaffDormAdjustValidator;

/**
 * Class StaffDormAdjustRepositoryEloquent.
 *
 * @package namespace App\Repositories;
 */
class StaffDormAdjustRepositoryEloquent extends BaseRepository implements StaffDormAdjustRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return StaffDormAdjust::class;
    }

    /**
    * Specify Validator class name
    *
    * @return mixed
    */
    public function validator()
    {

        return StaffDormAdjustValidator::class;
    }


    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }



    public function findLatestAdjust($staffId)
    {
        return $this->model::query()->where('staff_id',$staffId)->orderBy('id','desc')->first();
    }

    protected $fieldSearchable=[
        'staff.name',
        'staff.card_num',
        'dormFrom.code',
        'dormTo.code',
        'created_at'
    ];
    
}
